﻿using Zavand.Web.Mvc.Manana.Framework;

namespace Zavand.Web.Mvc.Manana.SampleWebsite.Controllers.My.Actions.Index
{
    public class Route : MyControllerRoute, IPageableOptional
    {
        public Route()
        {
            Action = "Index";
        }

        public string Category { get; set; }

        #region IPageableOptional Members

        public int? Page { get; set; }
        public int? PageSize { get; set; }

        #endregion

        public override object GetDefaults()
        {
            return new
                       {
                           Controller,
                           Action,
                           Page = 1,//BaseUrlParameter.Optional,
                           PageSize = 100//BaseUrlParameter.Optional
                       };
        }
        public override object GetConstraints()
        {
            return new
                   {
                       Page = "[0-9]+",
                       PageSize = "[0-9]+"
                   };
        }
        public override object GetConstraintsLocalized()
        {
            return new
                   {
//                       Locale = "en-US|ru-RU|es-ES|de-DE|fr-FR",
                       Page = "[0-9]+",
                       PageSize = "[0-9]+"
                   };
        }
        public override string GetUrl()
        {
            return MyController.ControllerName + "/{Page}/{PageSize}";
        }

        public override void MakeTheSameAs(BaseRoute r)
        {
            base.MakeTheSameAs(r);
            var o = r as Route;
            if (o == null)
                return;
            Page = o.Page;
            PageSize = o.PageSize;
            Category = o.Category;
        }
    }
}